/* eslint-disable no-undef */
import React, { useState } from 'react';
import { Form } from 'antd';
import { useHistory } from 'react-router-dom';
import qs from 'qs';
import { useEffectOnce } from 'react-use';
import { If, For } from 'babel-plugin-jsx-control-statements';
import RequestApi from '@/utils/request';
import css from '../index.scss';

/**
 * 停车管理备案中我的备案中查看经营管理者基本信息详情
 * -
 */
export default () => {
	const history = useHistory();
	const [data, setData] = useState();
	const search = qs.parse(history.location.search, { ignoreQueryPrefix: true });
	const { id } = search;
	useEffectOnce(() => {
		RequestApi.connection('get', `parkLotRecordTask/parkLotTaskInfo/${id}`).then((response) => {
			setData(response.data.rows.parkLotManagerBaseInfoDTO);
		});
	});

	return (
		<If condition={data !== undefined}>
			<div>
				<Form.Item className={css.item} label="停车场名称:">
					<span>{data.name}</span>
				</Form.Item>

				<Form.Item className={css.item}>
					<></>
				</Form.Item>

				<Form.Item className={css.item}>
					<></>
				</Form.Item>

				<Form.Item label="经营管理单位:" className={css.item}>
					<span>{data.manageOrgName}</span>
				</Form.Item>

				<Form.Item label="经营管理单位电话:" className={css.item}>
					<span>{data.manageOrgPhone}</span>
				</Form.Item>

				<Form.Item label="管理单位工商营业执照:" className={css.item_file}>
					<If condition={data.businessLicense !== null}>
						<For each="item" of={data.businessLicense}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>

				<Form.Item label="产权单位:" className={css.item}>
					<span>{data.propertyOrgName}</span>
				</Form.Item>

				<Form.Item label="产权单位电话:" className={css.item}>
					<span>{data.propertyOrgPhone}</span>
				</Form.Item>

				<Form.Item label="停车场产权单位证明:" className={css.item_file}>
					<If condition={data.propertyRight !== null}>
						<For each="item" of={data.propertyRight}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>

				<Form.Item label="与产权单位关系:" className={css.item}>
					<If condition={data.propertyOrgRelation === 0}>
						<span>租赁</span>
					</If>
					<If condition={data.propertyOrgRelation === 1}>
						<span>隶属</span>
					</If>
					<If condition={data.propertyOrgRelation === 2}>
						<span>自营</span>
					</If>
					<If condition={data.propertyOrgRelation === 3}>
						<span>共有</span>
					</If>
					<If condition={data.propertyOrgRelation === 4}>
						<span>抵押</span>
					</If>
					<If condition={data.propertyOrgRelation === 5}>
						<span>其他</span>
					</If>
				</Form.Item>

				<Form.Item label="使用权证明材料:" className={css.item_file}>
					<If condition={data.permissionRight !== null}>
						<For each="item" of={data.permissionRight}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>

				<Form.Item className={css.item}>
					<></>
				</Form.Item>

				<Form.Item label="经办人:" className={css.item}>
					<span>{data.managerName}</span>
				</Form.Item>

				<Form.Item label="经办人手机:" className={css.item}>
					<span>{data.managerPhone}</span>
				</Form.Item>

				<Form.Item label="单位授权办件委托书:" className={css.item_file}>
					<If condition={data.recommendation !== null}>
						<For each="item" of={data.recommendation}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>

				<Form.Item label="是否收费:" className={css.item}>
					<If condition={data.isCharge === 0}>
						<span>否</span>
					</If>
					<If condition={data.isCharge === 1}>
						<span>是</span>
					</If>
				</Form.Item>

				<Form.Item label="是否有停车优惠:" className={css.item}>
					<If condition={data.isParkFeeDiscount === 0}>
						<span>否</span>
					</If>
					<If condition={data.isParkFeeDiscount === 1}>
						<span>是</span>
					</If>
				</Form.Item>

				<Form.Item label="优惠说明:" className={css.item}>
					<If condition={data.feeDiscountExplain !== null}>
						<For each="item" of={data.feeDiscountExplain}>
							<a href={item.path} key={item.id}>
								{item.name}
							</a>
						</For>
					</If>
				</Form.Item>
			</div>
		</If>
	);
};
